<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>查看用工评价</title>
  <link rel="stylesheet" href="../../dist/css/layui.css">
  <script src="../../dist/layui.js"></script>
  <script src="../../dist/jquery-1_8_3.js"></script>
  <style>
    fieldset {
      background: rgba(255,255,255,.3);

      border-color: rgba(255,255,255,.6);

      border-style: solid;

      -moz-border-radius: 5px;

      -webkit-border-radius: 5px;

      border-radius: 5px;

      line-height: 30px;

      list-style: none;

      padding: 5px 10px;

      margin-bottom: 2px;

      border-width: 1px;

      border-color: #008000;

      width:97%;
    }
    legend {
      color:#302A2A;

      font: bold 16px/2 Verdana, Geneva, sans-serif;

      text-align: left;
    }
  </style>
</head>
<body>

<!--搜索框-->
<fieldset class="table-search-fieldset">
  <legend>搜索区</legend>
  <div style="margin: 10px 10px 10px 10px" id="btn">
    <form class="layui-form layui-form-pane" action="">
      <div class="layui-form-item">
        <div class="layui-inline">
          <label class="layui-form-label">学号</label>
          <div class="layui-input-inline">
            <input class="layui-input" name="keyword" id="uid" autocomplete="off" placeholder="请输入学号">
          </div>
          <label class="layui-form-label">姓名</label>
          <div class="layui-input-inline">
            <input class="layui-input" name="keyword" id="studentName" autocomplete="off" placeholder="请输入姓名">
          </div>
          <label class="layui-form-label">部门</label>
          <div class="layui-input-inline">
            <input class="layui-input" name="keyword" id="deptName" autocomplete="off" placeholder="请输入部门">
          </div>
        </div>

        <div class="layui-inline">
          <button type="button" class="layui-btn" id="submitButton"  data-type="reload" lay-filter="data-search-btn"><i class="layui-icon"></i> 搜索</button>
        </div>
      </div>
    </form>
  </div>
</fieldset>

<table id="demo" lay-filter="test"></table>

<script>
  layui.use('table', function(){
    var table = layui.table;

    //第一个实例
    table.render({
      elem: '#demo'
      ,height: "full-20"
      ,url: '/admin/selectWorkEvaluation' //数据接口
      ,page: {
        limit : 10,
        limits: [5, 10]
      } //开启分页
      ,id: 'tableSource'
      ,cols: [[ //表头
        {field: 'uid', title: '学号',align: "center", width:'15%'}
        ,{field: 'name', title: '姓名',align: "center", width:'15%'}
        ,{field: 'year', title: '学年',align: "center", width:'15%'}
        ,{field: 'term', title: '学期',align: "center", width:'15%'}
        ,{field: 'dept', title: '部门',align: "center", width:'15%'}
        ,{field: 'job', title: '岗位',align: "center", width:'15%'}
        ,{field: 'operation', title: '操作',  width:'10%', align:'center', toolbar: '#barDemo'}
      ]]
    });

    // 操作选项
    table.on('tool(test)', function (obj) {
      // 本行数据
      var data = obj.data;
      switch (obj.event) {
              //ajax
        case "select" :
          layer.open({
            type: 2,
            title: "评价内容",
            area: ['400px', '250px'],
            offset: 'auto',
            btn: '关闭',
            content: '/jsp/admin/work_evaluation_detail.jsp?id=' + data.id,
            yes: function (index, layero) {
              layer.close(index);
              return false;
            },
            //
            end: function () {
            }
          });
          break;
      }
    });

    var active = {
      reload: function(){
        // 学生学号
        var uid = $('#uid').val();
        // 学生姓名
        var studentName = $('#studentName').val();
        // 部门名
        var deptName = $('#deptName').val();
        //执行重载
        table.reload('tableSource', {
          page: {
            curr: 1 //重新从第 1 页开始
          }
          ,url: '/admin/selectWorkEvaluationByName'
          // 异步数据接口的额外参数
          ,where: {
            uid: uid.trim(),
            studentName: studentName.trim(),
            deptName: deptName.trim()
          }
        });
      }
    };
    // 搜索框提交
    $('#submitButton').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
  });
</script>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="select">查看评价</a>
</script>
</body>
</html>